import { IPublicTypeComponentMetadata, IPublicTypeSnippet } from '@alilc/lowcode-types';

const DensityDisplayMeta: IPublicTypeComponentMetadata = {
  componentName: 'DensityDisplay',
  title: '图标文字人数',
  category: '基础组件',
  group: '通用组件',
  docUrl: '',
  screenshot: '',
  devMode: 'proCode',
  npm: {
    package: 'hzdz-charts',
    version: '0.1.0',
    exportName: 'DensityDisplay',
    main: 'src/index.tsx',
    destructuring: true,
    subName: ''
  },
  props: [
    {
      name: 'ref',
      propType: 'object',
    },
    {
      name: 'key',
      propType: 'string',
    },
    {
      name: 'style',
      propType: 'object',
    },
  ],
  configure: {
    props: [
      // 基础配置
      {
        name: 'basic',
        type: 'group',
        display: 'accordion',
        title: {
          label: '基础配置',
        },
        items: [
          {
            name: 'moduleCount',
            title: {
              label: '模块数量',
              tip: '显示的模块数量，一行两个，自动计算行数'
            },
            setter: {
              componentName: 'NumberSetter',
              props: {
                min: 1,
                max: 12,
                step: 1
              }
            }
          },
          {
            name: 'dataItems',
            title: {
              label: '数据键值',
              tip: '每个模块的数据配置'
            },
            setter: {
              componentName: 'ArraySetter',
              props: {
                itemSetter: {
                  componentName: 'ObjectSetter',
                  props: {
                    config: {
                      items: [
                        {
                          name: 'label',
                          title: '标签文字',
                          setter: 'StringSetter'
                        },
                        {
                          name: 'value',
                          title: '数值',
                          setter: 'NumberSetter'
                        },
                        {
                          name: 'icon',
                          title: '图标路径',
                          setter: 'StringSetter'
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          {
            name: 'showValues',
            title: {
              label: '数值显示',
              tip: '是否显示数量数值'
            },
            setter: 'BoolSetter'
          },
        ]
      }
    ],
    supports: {
      style: true,
      className: true,
      events: ['onClick']
    },
    component: {}
  }
};

const snippets: IPublicTypeSnippet[] = [
  {
    title: '图标文字人数',
    screenshot: '',
    schema: {
      componentName: 'DensityDisplay',
      props: {
        moduleCount: 6, // 示例：4个模块，将显示为2行
        dataItems: [
          {
            label: '候车大厅',
            value: 870110,
            icon: 'http://localhost:8085/static/images/hcdt.png'
          },
          {
            label: '地铁',
            value: 870110,
            icon: 'http://localhost:8085/static/images/shouye/地铁.png'
          },
          {
            label: '到达层',
            value: 870110,
            icon: 'http://localhost:8085/static/images/shouye/到达层.png'
          },
          {
            label: '长运',
            value: 870110,
            icon: 'http://localhost:8085/static/images/shouye/长运.png'
          },
          {
            label: '出租车',
            value: 870110,
            icon: 'http://localhost:8085/static/images/shouye/出租车.png'
          },
          {
            label: '网约车',
            value: 870110,
            icon: 'http://localhost:8085/static/images/shouye/网约车.png'
          }
        ],
        iconType: 'passenger-hall',

        showValues: true,
        fontSize: 14
      }
    }
  }
];

export default {
  ...DensityDisplayMeta,
  snippets,
};
